package medium跳跃游戏;

import org.testng.annotations.Test;

public class Solution {
    public boolean canJump(int[] nums) {
        int n = nums.length;
        int rightmost = 0;
        for (int i = 0; i < n; ++i) {
            if (i <= rightmost) {
                rightmost = Math.max(rightmost, i + nums[i]);
                if (rightmost >= n - 1) {
                    return true;
                }
            }
        }
        return false;
    }
    @Test
    public void test(){
        int[] nums ={1,3,0,0,0};
        System.out.println(canJump(nums));
    }
}
